1
00:00:00,170 --> 00:00:03,530
In this video we're going to implement the ground slide ability.

2
00:00:03,530 --> 00:00:08,750
In this type of Megaman clone games, you usually have a slide that just makes you go faster and maybe

3
00:00:08,750 --> 00:00:09,710
has other properties.

4
00:00:09,710 --> 00:00:11,630
So we also want to implement this.

5
00:00:11,630 --> 00:00:15,440
But making something slight on the ground is actually surprisingly hard.

6
00:00:15,440 --> 00:00:16,460
In Unreal Engine.

7
00:00:16,460 --> 00:00:21,020
We've already used the launch character node before, and most tutorials you see will actually use this

8
00:00:21,020 --> 00:00:22,040
node for sliding.

9
00:00:22,040 --> 00:00:24,530
However, that is a very bad implementation.

10
00:00:24,530 --> 00:00:29,300
The problem with this is that you have to set it to a super high value to work against ground friction,

11
00:00:29,300 --> 00:00:33,830
but if you then use the slide near a latch, you're just going to fly off super far away.

12
00:00:34,250 --> 00:00:38,510
The best way for things like this is actually something like root motion.

13
00:00:38,510 --> 00:00:41,420
However, with 2D animations you don't really have root motion.

14
00:00:41,420 --> 00:00:46,400
That is more a 3D concept, and also you cannot control baked in root motion.

15
00:00:46,400 --> 00:00:52,430
So this is more like a root motion like solution that comes from the gameplay ability system.

16
00:00:52,430 --> 00:00:55,340
And you can look up the gameplay ability system of Unreal Engine.

17
00:00:55,340 --> 00:00:58,460
And it is a really big plugin that gives us many other features.

18
00:00:58,460 --> 00:01:04,849
However, we don't want to use this because this is very bloated for only wanting to use this one node.

19
00:01:04,849 --> 00:01:10,400
So I actually made a free plugin that only extracts the one node that we need for this root movement

20
00:01:10,400 --> 00:01:11,420
type of thing.

21
00:01:11,420 --> 00:01:15,140
And I'm going to show you how you can quickly install a free plugin like this.

22
00:01:15,140 --> 00:01:18,170
And then we're going to use it to actually implement the ground slide.

23
00:01:18,440 --> 00:01:23,690
I actually also made a YouTube video about this topic, which also shows examples from other real games.

24
00:01:23,690 --> 00:01:26,060
So you can also check that out in the resources.

25
00:01:26,060 --> 00:01:30,440
I'm not sure if it's already released by the time this course is out, but I will attach it once it

26
00:01:30,440 --> 00:01:31,400
is available.

27
00:01:31,400 --> 00:01:36,680
The plugin is called Root Movement and I'll attach it to this lesson in the resources, so please download

28
00:01:36,680 --> 00:01:37,400
it now.

29
00:01:37,400 --> 00:01:41,450
If you bought this course, of course, you can also feel free to use this plugin for all of your other

30
00:01:41,450 --> 00:01:42,350
projects.

31
00:01:42,350 --> 00:01:45,350
After downloading it, you should have this zip file again.

32
00:01:45,350 --> 00:01:47,630
We want to unzip this so extract.

33
00:01:48,350 --> 00:01:50,120
And in here we can just have a look.

34
00:01:50,120 --> 00:01:53,750
We have the root movement you plug in, we have the resources.

35
00:01:53,750 --> 00:01:55,310
And all of the files are in here.

36
00:01:55,310 --> 00:01:55,670
Right.

37
00:01:55,670 --> 00:02:01,790
So this is a packaged plugin that can be used in C plus plus projects and in blueprint projects as well.

38
00:02:02,090 --> 00:02:03,620
So how do we use this.

39
00:02:03,620 --> 00:02:10,669
Well we can go back to this folder the root movement 5.3 and just hit control X to cut this out.

40
00:02:10,669 --> 00:02:14,090
And we now need to add this plugin into our project.

41
00:02:14,090 --> 00:02:18,710
So this is not going to be an Unreal Engine version based plugin like paper Z and paper 2D.

42
00:02:18,740 --> 00:02:22,850
This is going to be a plugin we put specifically into this one project only.

43
00:02:22,850 --> 00:02:27,290
And we could then also develop this plugin alongside our game.

44
00:02:27,290 --> 00:02:33,800
The easiest way to find your project is to just find the project and right click and show in folder.

45
00:02:35,560 --> 00:02:39,460
And in here we then want to right click again and create a plugins folder.

46
00:02:39,460 --> 00:02:44,170
So new folder plugins and double click to open it up.

47
00:02:44,170 --> 00:02:49,060
And now we just paste our root movement plugin in here control and V.

48
00:02:49,700 --> 00:02:53,390
And for this to take effect, we actually have to restart our Unreal Engine project.

49
00:02:53,390 --> 00:02:54,920
So please do that now.

50
00:02:55,040 --> 00:02:58,010
Just go to the project and make sure that everything is saved.

51
00:02:58,010 --> 00:03:00,140
Save all and exit out.

52
00:03:03,070 --> 00:03:05,260
And then just open up your project again.

53
00:03:06,140 --> 00:03:11,510
And now you might get a message that says new plugins available and you can just click on Manage Plugins.

54
00:03:11,510 --> 00:03:16,340
Also, if it says project files out of date, just click on update and open the editor.

55
00:03:16,340 --> 00:03:17,450
This doesn't matter, right?

56
00:03:17,450 --> 00:03:20,570
But we can also just go here to edit and plugins.

57
00:03:20,570 --> 00:03:23,690
And now we just look for the root movement right.

58
00:03:23,690 --> 00:03:27,140
So this is the new root movement plugin made by Cobra Code.

59
00:03:27,140 --> 00:03:31,070
And it is already active because we restarted the project.

60
00:03:31,070 --> 00:03:34,520
And we can then see this in our content drawer.

61
00:03:34,520 --> 00:03:38,900
If we collapse the content we see the plugins folder here now right.

62
00:03:38,900 --> 00:03:43,070
And in here we have the root movement content, the root movement C plus plus class.

63
00:03:43,070 --> 00:03:46,280
And this is actually a C plus plus plugin that I created.

64
00:03:46,280 --> 00:03:50,870
If you have Visual Studio and everything installed you can actually look at the code in here if you

65
00:03:50,870 --> 00:03:51,470
want to.

66
00:03:51,470 --> 00:03:53,720
And you can get a better understanding of how this works.

67
00:03:53,720 --> 00:03:55,220
But we're not going to get too much into it.

68
00:03:55,220 --> 00:03:58,910
We're only gonna go over how we can actually use this in our blueprints.

69
00:03:59,390 --> 00:04:00,740
So how do we use this?

70
00:04:00,740 --> 00:04:03,290
Well, this has a function library.

71
00:04:03,290 --> 00:04:05,210
And what a function library does.

72
00:04:05,210 --> 00:04:09,770
Is it makes certain functions available in all other blueprints.

73
00:04:09,770 --> 00:04:11,210
And this is how I set this up.

74
00:04:11,210 --> 00:04:16,850
So simply by having this installed in the plugins folder, I can now access this in any blueprint that

75
00:04:16,850 --> 00:04:17,690
I want to.

76
00:04:17,690 --> 00:04:20,570
And we want to access this of course in the player.

77
00:04:20,570 --> 00:04:25,850
So blueprints characters player and go to BP player.

78
00:04:27,120 --> 00:04:29,310
And in here we now want to.

79
00:04:29,310 --> 00:04:34,740
Well, first of all, we want to go to the event graph and look for our jump for the IA jump.

80
00:04:35,840 --> 00:04:41,750
And the way we want to trigger the slide is if we press jump while down is also being held.

81
00:04:42,600 --> 00:04:47,040
But for now, let's just use this on jump and just see how it works.

82
00:04:47,040 --> 00:04:50,550
So for now, we just click alt and here and stop the jumping.

83
00:04:50,550 --> 00:04:52,890
And instead we just want to use this for the sliding.

84
00:04:52,890 --> 00:04:54,120
Now for testing.

85
00:04:54,120 --> 00:04:58,620
And I can just drag off here and just type in root motion.

86
00:04:58,620 --> 00:05:04,830
And here we have these two functions the apply root motion constant force and apply root motion constant

87
00:05:04,830 --> 00:05:06,420
force with callbacks.

88
00:05:06,420 --> 00:05:10,080
And these are the two functions I created which are in this plugin.

89
00:05:10,170 --> 00:05:12,990
So the first one doesn't have any callbacks.

90
00:05:12,990 --> 00:05:18,360
And this is a monstrosity if you look at it first because it has a lot of functionality built in, you

91
00:05:18,360 --> 00:05:21,540
don't need to understand everything that happens here, but just the basics.

92
00:05:21,840 --> 00:05:25,050
The one problem with this though, is that it only has an input and an output.

93
00:05:25,050 --> 00:05:30,870
It doesn't tell us when the event is over, it doesn't give us a way to cancel the event.

94
00:05:30,870 --> 00:05:35,160
But if you just want to trigger something and just let it happen, don't worry about it anymore.

95
00:05:35,160 --> 00:05:40,140
You could use this, but we actually want to be able to cancel the slide if we get hit or get stunned,

96
00:05:40,140 --> 00:05:40,950
for example.

97
00:05:40,950 --> 00:05:47,190
So again, we want to look for root motion and we want to apply root motion constant force with callbacks.

98
00:05:47,190 --> 00:05:50,070
And this gives us and actually connect to the right side.

99
00:05:50,070 --> 00:05:55,410
For some reason I go from started to the left side and then disconnect this in case this also happened

100
00:05:55,410 --> 00:05:55,830
for you.

101
00:05:55,830 --> 00:05:59,940
And this actually gives us the Oncompleted event, the on fail event.

102
00:05:59,940 --> 00:06:02,130
And it also gives us the async action.

103
00:06:02,130 --> 00:06:04,740
And here we can actually call cancel.

104
00:06:04,800 --> 00:06:11,340
So if we get stunned or something happens, we can just link in here and cancel the slide.

105
00:06:11,340 --> 00:06:12,330
The slide movement.

106
00:06:12,330 --> 00:06:14,430
So this is very important.

107
00:06:14,430 --> 00:06:16,380
But for now let's just try it out.

108
00:06:16,380 --> 00:06:18,180
What happens if we put something in here.

109
00:06:18,180 --> 00:06:18,540
Right.

110
00:06:18,540 --> 00:06:23,760
So the first important thing is that we need the character movement component, which we want to call

111
00:06:23,760 --> 00:06:25,200
this root motion on.

112
00:06:25,200 --> 00:06:29,070
So we can just grab the character movement and pass it in here.

113
00:06:29,070 --> 00:06:30,570
Otherwise nothing is going to work.

114
00:06:30,570 --> 00:06:33,390
So this is very important for the world direction.

115
00:06:33,390 --> 00:06:36,270
We can just get actor forward vector.

116
00:06:36,270 --> 00:06:40,920
And this is just going to give us a x of plus 1 or -1 for left or right.

117
00:06:40,920 --> 00:06:44,280
Strength is of course how much power we want to give the movement.

118
00:06:44,280 --> 00:06:48,540
And for now just put in like something like 700 for testing.

119
00:06:48,540 --> 00:06:52,260
And the duration is of course, how long the slide is going to be or the movement.

120
00:06:52,260 --> 00:06:52,440
Right.

121
00:06:52,440 --> 00:06:54,990
Because you could also use this for other types of movements.

122
00:06:54,990 --> 00:06:58,440
And I think 0.2 is a good value to start from.

123
00:06:58,980 --> 00:07:01,470
And the rest is actually not so important.

124
00:07:01,470 --> 00:07:02,850
These are just additional things.

125
00:07:02,850 --> 00:07:03,870
Features we can use.

126
00:07:03,870 --> 00:07:09,120
You could pass a curve, for example, to make this light start out very fast and slow down over time.

127
00:07:09,330 --> 00:07:14,610
We could carry on the velocity if you jump out of the slide like in Donkey Kong games in the Donkey

128
00:07:14,610 --> 00:07:16,650
Kong country, uh, remakes.

129
00:07:16,650 --> 00:07:22,740
This is a very, very often used gameplay mechanic where you just use your dash kind of to build up

130
00:07:22,740 --> 00:07:26,640
momentum, and then you jump out of it to carry that momentum into your jump.

131
00:07:26,640 --> 00:07:30,090
And this is what happens if we maintain the last root motion velocity.

132
00:07:30,090 --> 00:07:31,200
So I like the setting.

133
00:07:31,200 --> 00:07:32,400
You could clamp it.

134
00:07:32,400 --> 00:07:34,170
You could set it all of these things.

135
00:07:34,170 --> 00:07:37,650
And also important is the enable gravity.

136
00:07:37,650 --> 00:07:43,290
So if you want to make an air dash or something like that which should ignore gravity, we can just

137
00:07:43,290 --> 00:07:43,800
keep it off.

138
00:07:43,800 --> 00:07:45,450
But we actually want to make a slide.

139
00:07:45,450 --> 00:07:49,230
So if we slide off a ledge we actually do want gravity to take effect.

140
00:07:49,230 --> 00:07:51,870
So we want to check this and set it to true.

141
00:07:51,900 --> 00:07:52,500
Right.

142
00:07:52,500 --> 00:07:55,440
So now we set up the basic things here.

143
00:07:55,440 --> 00:07:56,550
Let's just try it out.

144
00:07:56,550 --> 00:07:59,910
Go to the map and I press jump or Space.

145
00:07:59,910 --> 00:08:03,780
And you can see we get this nice little slide right.

146
00:08:03,780 --> 00:08:06,780
And you cannot steer against it and things like that.

147
00:08:06,780 --> 00:08:07,170
Right.

148
00:08:07,170 --> 00:08:09,420
It kind of takes over your character.

149
00:08:10,200 --> 00:08:11,820
But we aren't playing the animation yet.

150
00:08:11,820 --> 00:08:12,960
But this is working.

151
00:08:12,960 --> 00:08:14,460
So this is the movement itself.

152
00:08:14,460 --> 00:08:15,660
It is working.

153
00:08:16,230 --> 00:08:23,040
So now that the slide itself is working, we want to just use this for the jumping again, right?

154
00:08:23,040 --> 00:08:25,290
We can just use the started for the jumping again.

155
00:08:25,290 --> 00:08:31,830
And we actually want to introduce a branch here so that if we press jump and our holding down we then

156
00:08:31,830 --> 00:08:33,450
want to execute this instead.

157
00:08:33,450 --> 00:08:37,230
But we actually don't have an input for up and down assigned yet.

158
00:08:37,230 --> 00:08:39,840
So we first need to do that with the input system.

159
00:08:40,260 --> 00:08:46,530
Go to the content drawer and the content input folder and actions.

160
00:08:46,530 --> 00:08:48,900
We already have the IA move right?

161
00:08:48,900 --> 00:08:55,470
But because we can only walk left and right in our game so far we only set it up as an axis mundi.

162
00:08:55,470 --> 00:09:00,360
But actually now we also want to have the down and up input, the down input we want for the sliding,

163
00:09:00,360 --> 00:09:05,910
like I said before, but later on we are also going to implement ladder climbing and for climbing.

164
00:09:05,910 --> 00:09:08,190
We also want to have the up input as well.

165
00:09:08,190 --> 00:09:12,060
So we can just go from axis 1D now and go to axis 2D.

166
00:09:12,060 --> 00:09:16,050
So this will give us left, right, up and down at the same time.

167
00:09:17,130 --> 00:09:22,560
And we want to save this and go to the input, the IMC action.

168
00:09:22,560 --> 00:09:28,500
So nothing has changed yet, but we are now able to also put in more buttons for up and down.

169
00:09:28,500 --> 00:09:29,100
Right?

170
00:09:29,100 --> 00:09:33,600
So under the I move I now want to implement the button for up.

171
00:09:33,600 --> 00:09:39,000
First let's just do this and add one here and put it to W.

172
00:09:39,270 --> 00:09:43,350
And the default axis for movement is left and right.

173
00:09:43,350 --> 00:09:45,810
So that is y D and A are working.

174
00:09:45,810 --> 00:09:48,900
But for w we need to add another modifier.

175
00:09:48,900 --> 00:09:54,420
So for modifier we actually want to use the swizzle input axis values.

176
00:09:54,420 --> 00:09:58,830
And this just lets us go from an x axis to a y axis.

177
00:09:59,160 --> 00:10:04,710
And this is all it takes because for the y axis up is the default direction.

178
00:10:04,710 --> 00:10:06,120
So then add another one.

179
00:10:06,120 --> 00:10:08,910
And here instead of w we want to click on s.

180
00:10:08,910 --> 00:10:12,420
And s is the down button for wasD controls.

181
00:10:12,420 --> 00:10:15,990
And again here we need to swizzle on the modifiers.

182
00:10:15,990 --> 00:10:18,930
Swizzle input axis to go on the y axis.

183
00:10:18,930 --> 00:10:22,050
But here we also need to negate like we did for the A right.

184
00:10:22,050 --> 00:10:26,250
Because A is left, we had to negate it, as you can see here.

185
00:10:26,250 --> 00:10:28,110
So for the S we just do the same thing.

186
00:10:28,110 --> 00:10:30,300
Just add another one on top of swizzle.

187
00:10:30,300 --> 00:10:33,810
We also want to negate and then just save this.

188
00:10:33,810 --> 00:10:35,490
If we go back to our blueprints.

189
00:10:35,490 --> 00:10:38,880
Now compile and save, we're actually going to get an error right.

190
00:10:38,880 --> 00:10:42,420
So this is well we can just click here to see what's going on.

191
00:10:42,420 --> 00:10:46,680
And the problem is that our IA move now turned into a vector 2D.

192
00:10:46,920 --> 00:10:48,720
So we can actually start at the first one.

193
00:10:48,720 --> 00:10:48,930
Right.

194
00:10:48,930 --> 00:10:51,990
So the uh enhanced input IA move.

195
00:10:51,990 --> 00:10:56,730
Now these uh now these pins don't match anymore.

196
00:10:56,730 --> 00:10:58,650
So these are for the X right.

197
00:10:58,650 --> 00:10:59,340
We want the x.

198
00:10:59,340 --> 00:11:05,040
So here we can just disconnect this and we right click and break uh split struct pin.

199
00:11:05,040 --> 00:11:07,440
And now we can split the x and the y.

200
00:11:07,470 --> 00:11:11,580
So here we need the x right for the left and right movement.

201
00:11:11,580 --> 00:11:12,600
And for the rotation.

202
00:11:12,600 --> 00:11:17,640
We just need the x and the y we can then use for other things later like the ladder climbing.

203
00:11:17,640 --> 00:11:19,140
But now just compile and save.

204
00:11:19,140 --> 00:11:22,920
But there's still something left here like the float times float right?

205
00:11:22,920 --> 00:11:28,650
Because for the tri wall slide, if we check if we are looking towards the wall and pressing towards

206
00:11:28,650 --> 00:11:30,720
the wall, we also just check the x.

207
00:11:30,720 --> 00:11:33,720
So here we can again disconnect this hold alt and left click.

208
00:11:33,720 --> 00:11:37,230
And here split the struct pin and we only use the x.

209
00:11:37,230 --> 00:11:39,300
In this case we don't care about the y at all.

210
00:11:39,300 --> 00:11:40,980
And we can just compile and save.

211
00:11:40,980 --> 00:11:44,370
And for now let's just go in here and everything works again, right?

212
00:11:44,370 --> 00:11:45,150
We can walk.

213
00:11:45,150 --> 00:11:46,680
The wall slide is working.

214
00:11:46,680 --> 00:11:48,240
The jumping is working again.

215
00:11:48,240 --> 00:11:54,750
But now we have set up the inputs which we can use for the climbing and also for the sliding.

216
00:11:55,200 --> 00:11:57,480
So now let's set up the sliding.

217
00:11:57,480 --> 00:12:00,450
And again in the BP player this getea move.

218
00:12:00,450 --> 00:12:03,000
We actually want to use this for the slide as well.

219
00:12:03,000 --> 00:12:06,810
So we can just copy this and go to the event graph.

220
00:12:06,810 --> 00:12:08,280
And we can look for our IA.

221
00:12:08,280 --> 00:12:10,950
Jump right to teleport here.

222
00:12:10,950 --> 00:12:14,160
And now here we want to add yet another branch.

223
00:12:14,160 --> 00:12:16,410
So first we just check for is wall sliding.

224
00:12:16,410 --> 00:12:19,800
And if we are not wall sliding well then we want to check.

225
00:12:19,800 --> 00:12:21,210
Are we holding down.

226
00:12:21,210 --> 00:12:23,730
And then decide do we jump or do we slide.

227
00:12:24,790 --> 00:12:28,180
So here we can just drag off and branch another time.

228
00:12:29,000 --> 00:12:34,970
And here we can just, uh, control V to put in our get move.

229
00:12:34,970 --> 00:12:39,140
If you didn't copy it, we can just look for get IA, move here as well and use this.

230
00:12:39,140 --> 00:12:45,320
And here we just want to check if the Y which is the up and down if this is less than zero.

231
00:12:45,320 --> 00:12:45,800
Right.

232
00:12:45,800 --> 00:12:48,530
So this means we are currently holding down.

233
00:12:48,530 --> 00:12:52,190
And I can just add a comment here is holding down.

234
00:12:53,050 --> 00:12:54,640
Add a small o.

235
00:12:57,270 --> 00:12:58,230
Like this.

236
00:12:58,440 --> 00:12:58,890
Right.

237
00:12:58,890 --> 00:13:01,290
So if we are holding down, I actually want to change this.

238
00:13:01,290 --> 00:13:02,340
So hold Ctrl.

239
00:13:02,340 --> 00:13:04,620
And if we are not holding down we want to jump.

240
00:13:04,620 --> 00:13:05,640
This is fine.

241
00:13:05,640 --> 00:13:09,480
If we are holding down well then we want to slide.

242
00:13:09,480 --> 00:13:14,580
So we can use this here this monstrosity of a node.

243
00:13:14,580 --> 00:13:19,620
And if we are holding down while jumping, well we can do the slide instead.

244
00:13:19,620 --> 00:13:20,670
Compile and save.

245
00:13:20,670 --> 00:13:21,720
And let's check this out.

246
00:13:21,720 --> 00:13:23,970
I'm not holding down, I'm just pressing jump.

247
00:13:23,970 --> 00:13:25,860
I'm jumping, I'm holding down.

248
00:13:26,280 --> 00:13:29,730
And now kind of sliding over to the side.

249
00:13:31,470 --> 00:13:31,920
Right.

250
00:13:31,920 --> 00:13:32,430
Jumping.

251
00:13:32,430 --> 00:13:33,210
Sliding.

252
00:13:34,890 --> 00:13:40,590
One problem you might notice here is that if I press down now, the character just starts looking to

253
00:13:40,590 --> 00:13:43,350
the right side, even if I just press down and no direction.

254
00:13:43,350 --> 00:13:48,660
And this is actually related to the changes we made to the 1D and 2D axis.

255
00:13:48,660 --> 00:13:50,460
So let's just fix this quickly.

256
00:13:50,670 --> 00:13:53,730
We can fix this on the IA move event.

257
00:13:53,730 --> 00:13:56,100
So here we can just look for IA move.

258
00:13:57,250 --> 00:13:59,740
Uh, not the getai move, but the input action.

259
00:13:59,740 --> 00:14:06,070
So what changed now is that this triggered is not only active if we press left or right, but this is

260
00:14:06,070 --> 00:14:09,100
actually also activated if we press up or down.

261
00:14:09,100 --> 00:14:13,840
And this means if we press up or down, this access value for x is going to be zero.

262
00:14:13,840 --> 00:14:19,630
So inside of this update rotation we had this check of if bigger or equals than zero we look to the

263
00:14:19,630 --> 00:14:20,170
right.

264
00:14:20,170 --> 00:14:22,900
So if we press up or down this is going to be zero.

265
00:14:22,900 --> 00:14:24,010
This is going to be triggered.

266
00:14:24,010 --> 00:14:25,750
And we're going to look to the right side.

267
00:14:25,750 --> 00:14:29,800
So we have to add one more branch in here to check that edge case.

268
00:14:29,800 --> 00:14:32,440
So here we can just branch.

269
00:14:33,310 --> 00:14:39,250
At a branch here, and we want to check that the direction does not equal zero.

270
00:14:39,670 --> 00:14:40,570
Like this.

271
00:14:44,820 --> 00:14:46,050
And just like this.

272
00:14:46,410 --> 00:14:47,250
Right.

273
00:14:47,250 --> 00:14:51,360
And here we also got to be careful with the float rounding issues.

274
00:14:51,360 --> 00:14:53,310
But actually this worked out for me.

275
00:14:53,310 --> 00:14:55,710
Like I don't have to check the nearly equal.

276
00:14:55,710 --> 00:14:56,100
Right.

277
00:14:56,100 --> 00:14:57,360
We could also put in the nearly equal.

278
00:14:57,360 --> 00:14:59,730
But actually this one worked out for me in this case.

279
00:14:59,730 --> 00:15:05,400
But it is something we should keep in mind with the floating point errors that are common in computers.

280
00:15:05,400 --> 00:15:07,260
But for now, this is working fine.

281
00:15:08,620 --> 00:15:09,610
And let's try this out.

282
00:15:09,640 --> 00:15:13,810
Now, if we go here, right, I look to the left, I press down.

283
00:15:13,810 --> 00:15:14,410
It is fine.

284
00:15:14,410 --> 00:15:15,910
We don't flip to the other side.

285
00:15:15,910 --> 00:15:18,730
And if I hold down and jump, we can slide left.

286
00:15:18,730 --> 00:15:21,490
If I turn it to the right, hold down and jump, we can slide.

287
00:15:21,490 --> 00:15:25,000
And if I just jump, we can jump while walking, right?

288
00:15:25,000 --> 00:15:27,490
So we have not technically implemented the slide.

289
00:15:27,490 --> 00:15:31,990
Of course we still want to polish it up, but we can jump, we can slide, we can turn around, we can

290
00:15:31,990 --> 00:15:32,500
wall slide.

291
00:15:32,500 --> 00:15:34,060
All of this is still working.

292
00:15:34,640 --> 00:15:39,380
But before we start polishing up the values we use for the slide, I first want to implement the animation

293
00:15:39,380 --> 00:15:43,490
because things are just easier to understand once they actually look like sliding.

294
00:15:43,490 --> 00:15:50,300
So go back to the BP player and for the Aya jump, go to the Aya Jump event.

295
00:15:51,500 --> 00:15:52,340
And here.

296
00:15:52,340 --> 00:15:52,850
Right.

297
00:15:52,850 --> 00:15:59,630
So before we start sliding, like we did for the wall slide, we want to use a boolean to save the state.

298
00:15:59,630 --> 00:16:00,140
Right.

299
00:16:00,140 --> 00:16:05,990
So here we just create another variable and just called this sliding or just call.

300
00:16:05,990 --> 00:16:09,890
It is ground sliding to make sure there's no confusion.

301
00:16:10,160 --> 00:16:11,930
And if we press the button here right.

302
00:16:11,930 --> 00:16:14,150
We set this ground sliding to true.

303
00:16:14,630 --> 00:16:16,850
And then we go into this animation.

304
00:16:17,480 --> 00:16:22,400
And we then want to set this back to false, which is great that we have the callbacks here, right?

305
00:16:22,400 --> 00:16:28,370
We don't want to do this here because this happens right away even before the force ends.

306
00:16:28,370 --> 00:16:32,450
So oncomplete we want to set it to false and on fail.

307
00:16:32,450 --> 00:16:33,860
We also want to set it to false.

308
00:16:33,860 --> 00:16:34,880
The sliding right.

309
00:16:34,880 --> 00:16:39,950
So this is just a nice way we can handle the animation through our callback events.

310
00:16:39,950 --> 00:16:43,580
Now of course we also need to add this to the animation blueprint.

311
00:16:43,970 --> 00:16:47,120
Go to the content drawer in the blueprints characters player.

312
00:16:47,120 --> 00:16:48,680
The ABP player.

313
00:16:48,680 --> 00:16:52,340
We now want to add a new state for the sliding.

314
00:16:52,340 --> 00:16:57,590
So here from the idle we can go to the animation state.

315
00:16:58,310 --> 00:17:04,280
And add in slide here and just open it up and here just play slide.

316
00:17:04,280 --> 00:17:06,050
And for sliding there is no shooting.

317
00:17:06,050 --> 00:17:08,720
We are going to prevent shooting while we are sliding.

318
00:17:08,720 --> 00:17:10,280
So just play slide here.

319
00:17:11,000 --> 00:17:12,349
And go back out.

320
00:17:12,349 --> 00:17:17,839
And the condition here, of course, is from the idle owning player is sliding.

321
00:17:19,470 --> 00:17:24,030
And I think we just have to compile and save because it doesn't know about this variable yet.

322
00:17:24,300 --> 00:17:25,890
And actually it was my mistake.

323
00:17:25,890 --> 00:17:27,839
It is called is ground sliding.

324
00:17:29,270 --> 00:17:31,550
And this is the transitional condition here.

325
00:17:31,550 --> 00:17:32,090
Right.

326
00:17:32,090 --> 00:17:37,670
And we can copy this, go back out to locomotion and to go from sliding back to idle, we just do the

327
00:17:37,670 --> 00:17:44,930
same thing and go here and just copy paste this in and then just use the not boolean to completely flip

328
00:17:44,930 --> 00:17:45,650
it around.

329
00:17:46,880 --> 00:17:49,070
And we can then just connect this here.

330
00:17:49,070 --> 00:17:49,340
Right.

331
00:17:49,340 --> 00:17:52,310
So we can go from idle to slide and from slide to idle.

332
00:17:52,310 --> 00:17:57,590
But actually it is also very common from run actually more so common to go into the slide.

333
00:17:57,590 --> 00:18:00,020
So we can also go from run into the slide.

334
00:18:00,020 --> 00:18:02,090
And we can just copy these conditions.

335
00:18:02,090 --> 00:18:06,740
The is ground sliding to go here and just do this.

336
00:18:08,520 --> 00:18:11,580
And now you'd think that maybe we also have to go from slide to run.

337
00:18:11,580 --> 00:18:16,650
But actually, like I said before, if we end the slide, it's going to go to idle and it's going to

338
00:18:16,650 --> 00:18:17,970
try to go to run right away.

339
00:18:17,970 --> 00:18:20,070
It's going to evaluate on the same frame.

340
00:18:20,070 --> 00:18:23,910
So we're not even going to get like a single frame of idle if we are able to run.

341
00:18:23,910 --> 00:18:25,860
And this is just a cleaner way.

342
00:18:25,860 --> 00:18:29,070
Of course, we could also go back, but it would have the same result.

343
00:18:30,340 --> 00:18:31,840
Now let's try this out.

344
00:18:31,840 --> 00:18:36,850
Go into the map, hold down and jump and you can see the nice slide animation.

345
00:18:36,850 --> 00:18:38,620
It is aligned correctly already, right?

346
00:18:38,620 --> 00:18:40,750
Like all of this is working out nicely.

347
00:18:40,870 --> 00:18:43,000
And now we can tell the slide is a little bit short.

348
00:18:43,000 --> 00:18:47,110
So we might want to adjust some values to make it more useful.

349
00:18:47,110 --> 00:18:48,070
But it looks cool.

350
00:18:48,070 --> 00:18:49,240
It is working out.

351
00:18:49,800 --> 00:18:51,240
Now back in the player.

352
00:18:51,240 --> 00:18:54,300
We just want to change a couple of these values, right.

353
00:18:54,480 --> 00:19:00,660
So I want to change the duration to 0.3 to make it a little bit longer and also make it stronger.

354
00:19:00,660 --> 00:19:02,790
So strength of 1000.

355
00:19:03,760 --> 00:19:07,030
And of course these should again be variables.

356
00:19:07,030 --> 00:19:10,240
So from the strength we can just drag off promote the variable.

357
00:19:10,240 --> 00:19:12,190
And it's called slide strength.

358
00:19:13,660 --> 00:19:18,430
And drag out from the duration and just call it slide duration.

359
00:19:19,280 --> 00:19:21,740
And just like this and test it out again.

360
00:19:21,740 --> 00:19:22,850
Compile and save.

361
00:19:23,000 --> 00:19:24,020
Go back in here.

362
00:19:24,020 --> 00:19:24,440
And yeah.

363
00:19:24,440 --> 00:19:28,070
So this is a more useful slide from a gameplay perspective.

364
00:19:29,440 --> 00:19:31,360
And yet everything else still works.

365
00:19:31,360 --> 00:19:36,490
And this kind of showed you how we can use a custom made plugin to use it in here.

366
00:19:36,490 --> 00:19:43,540
And to overcome this like very hard problem of sliding by using the root motion that is built into Unreal

367
00:19:43,540 --> 00:19:44,050
Engine.

368
00:19:44,050 --> 00:19:49,600
However, you would have to install the whole gameplay ability system, which is a very complicated.

369
00:19:49,600 --> 00:19:54,130
But through my plugin you just get easy access to the one node that we need.

370
00:19:54,130 --> 00:19:57,040
There are still a couple of edge cases and problems with the slides.

371
00:19:57,040 --> 00:20:00,880
In the next video, we're going to make some adjustments to it and improve it even further.


